#include "FileReader.h"

myDBMS::FileReader::FileReader(const std::string& new_file_name) :file_name(new_file_name)
{
	read();
}

void myDBMS::FileReader::printFile()
{
	std::cout << "--------------------------------------------------------------------------------\n";
	std::cout << "This file's name is: " << this->file_name << std::endl;
	std::cout << "This file is: " << std::endl;
	std::cout << "--------------------------------------------------------------------------------\n";
	int n = this->every_line_of_file.size();
	for (int i = 0; i < n; i++)
	{
		std::cout << this->every_line_of_file[i] << std::endl;
	}
	std::cout << "--------------------------------------------------------------------------------\n";
}

std::vector<std::string> myDBMS::FileReader::getEveryLineOfFile()
{
	return every_line_of_file;
}

void myDBMS::FileReader::read()
{
	std::ifstream fin(file_name.c_str(), std::ios::in);
	std::string assist = "";
	while (getline(fin, assist))
	{
		for (int i = 0; i < assist.size(); i++)
		{
			if (assist[i] >= 'A' && assist[i] <= 'Z')
			{
				assist[i] = assist[i] + 'a' - 'A';
			}
		}
		every_line_of_file.push_back(assist);
		assist = "";
	}
}